package com.interauto.service.web;

import com.interauto.Dao.Mapper.MgProjectTable;
import com.interauto.Dao.entity.Projectauto;
import com.interauto.bean.web.ProjectInfoWeb;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * 处理项目相关的
 */
@Component
public class ProPageService {
    private static final Logger logger= LoggerFactory.getLogger(ProPageService.class);
    @Autowired
    private MgProjectTable mgProjectTable;

    public List<ProjectInfoWeb> getAllProjectInfoWeb(){
        try{
            List<Projectauto> projectautos=mgProjectTable.getProjectauto();
            if(projectautos == null || projectautos.size()<1){
                return null;
            }
            List<ProjectInfoWeb> projectInfoWebs=new ArrayList<>();
            for(Projectauto projectauto:projectautos){
                System.out.println("--1>>>"+projectauto.toString());
                ProjectInfoWeb obj=new ProjectInfoWeb();
                BeanUtils.copyProperties(projectauto,obj);
                System.out.println("--2>>>"+obj.toString());
                projectInfoWebs.add(obj);
            }
            return projectInfoWebs;
        }
        catch (Exception e){
            logger.error("-->>getAllProjectInfoWeb is system error-->"+e);
            return null;
        }
    }
}
